# 全部命令  https://redis.io/commands/
ALL_REDIS_COMMAND_LIST = [
    "ACL CAT",
    "ACL DELUSER",
    "ACL DRYRUN",
    "ACL GENPASS",
    "ACL GETUSER",
    "ACL LIST",
    "ACL LOAD",
    "ACL LOG",
    "ACL SAVE",
    "ACL SETUSER",
    "ACL USERS",
    "ACL WHOAMI",
    "APPEND",
    "ASKING",
    "AUTH",
    "BF.ADD",
    "BF.CARD",
    "BF.EXISTS",
    "BF.INFO",
    "BF.INSERT",
    "BF.LOADCHUNK",
    "BF.MADD",
    "BF.MEXISTS",
    "BF.RESERVE",
    "BF.SCANDUMP",
    "BGREWRITEAOF",
    "BGSAVE",
    "BITCOUNT",
    "BITFIELD",
    "BITFIELD_RO",
    "BITOP",
    "BITPOS",
    "BLMOVE",
    "BLMPOP",
    "BLPOP",
    "BRPOP",
    "BRPOPLPUSH",
    "BZMPOP",
    "BZPOPMAX",
    "BZPOPMIN",
    "CF.ADD",
    "CF.ADDNX",
    "CF.COUNT",
    "CF.DEL",
    "CF.EXISTS",
    "CF.INFO",
    "CF.INSERT",
    "CF.INSERTNX",
    "CF.LOADCHUNK",
    "CF.MEXISTS",
    "CF.RESERVE",
    "CF.SCANDUMP",
    "CLIENT CACHING",
    "CLIENT GETNAME",
    "CLIENT GETREDIR",
    "CLIENT ID",
    "CLIENT INFO",
    "CLIENT KILL",
    "CLIENT LIST",
    "CLIENT NO-EVICT",
    "CLIENT NO-TOUCH",
    "CLIENT PAUSE",
    "CLIENT REPLY",
    "CLIENT SETINFO",
    "CLIENT SETNAME",
    "CLIENT TRACKING",
    "CLIENT TRACKINGINFO",
    "CLIENT UNBLOCK",
    "CLIENT UNPAUSE",
    "CLUSTER ADDSLOTS",
    "CLUSTER ADDSLOTSRANGE",
    "CLUSTER BUMPEPOCH",
    "CLUSTER COUNT-FAILURE-REPORTS",
    "CLUSTER COUNTKEYSINSLOT",
    "CLUSTER DELSLOTS",
    "CLUSTER DELSLOTSRANGE",
    "CLUSTER FAILOVER",
    "CLUSTER FLUSHSLOTS",
    "CLUSTER FORGET",
    "CLUSTER GETKEYSINSLOT",
    "CLUSTER INFO",
    "CLUSTER KEYSLOT",
    "CLUSTER LINKS",
    "CLUSTER MEET",
    "CLUSTER MYID",
    "CLUSTER MYSHARDID",
    "CLUSTER NODES",
    "CLUSTER REPLICAS",
    "CLUSTER REPLICATE",
    "CLUSTER RESET",
    "CLUSTER SAVECONFIG",
    "CLUSTER SET-CONFIG-EPOCH",
    "CLUSTER SETSLOT",
    "CLUSTER SHARDS",
    "CLUSTER SLAVES",
    "CLUSTER SLOTS",
    "CMS.INCRBY",
    "CMS.INFO",
    "CMS.INITBYDIM",
    "CMS.INITBYPROB",
    "CMS.MERGE",
    "CMS.QUERY",
    "COMMAND",
    "COMMAND COUNT",
    "COMMAND DOCS",
    "COMMAND GETKEYS",
    "COMMAND GETKEYSANDFLAGS",
    "COMMAND INFO",
    "COMMAND LIST",
    "CONFIG GET",
    "CONFIG RESETSTAT",
    "CONFIG REWRITE",
    "CONFIG SET",
    "COPY",
    "DBSIZE",
    "DECR",
    "DECRBY",
    "DEL",
    "DISCARD",
    "DUMP",
    "ECHO",
    "EVAL",
    "EVAL_RO",
    "EVALSHA",
    "EVALSHA_RO",
    "EXEC",
    "EXISTS",
    "EXPIRE",
    "EXPIREAT",
    "EXPIRETIME",
    "FAILOVER",
    "FCALL",
    "FCALL_RO",
    "FLUSHALL",
    "FLUSHDB",
    "FT._LIST",
    "FT.AGGREGATE",
    "FT.ALIASADD",
    "FT.ALIASDEL",
    "FT.ALIASUPDATE",
    "FT.ALTER",
    "FT.CONFIG GET",
    "FT.CONFIG SET",
    "FT.CREATE",
    "FT.CURSOR DEL",
    "FT.CURSOR READ",
    "FT.DICTADD",
    "FT.DICTDEL",
    "FT.DICTDUMP",
    "FT.DROPINDEX",
    "FT.EXPLAIN",
    "FT.EXPLAINCLI",
    "FT.INFO",
    "FT.PROFILE",
    "FT.SEARCH",
    "FT.SPELLCHECK",
    "FT.SUGADD",
    "FT.SUGDEL",
    "FT.SUGGET",
    "FT.SUGLEN",
    "FT.SYNDUMP",
    "FT.SYNUPDATE",
    "FT.TAGVALS",
    "FUNCTION DELETE",
    "FUNCTION DUMP",
    "FUNCTION FLUSH",
    "FUNCTION KILL",
    "FUNCTION LIST",
    "FUNCTION LOAD",
    "FUNCTION RESTORE",
    "FUNCTION STATS",
    "GEOADD",
    "GEODIST",
    "GEOHASH",
    "GEOPOS",
    "GEORADIUS",
    "GEORADIUS_RO",
    "GEORADIUSBYMEMBER",
    "GEORADIUSBYMEMBER_RO",
    "GEOSEARCH",
    "GEOSEARCHSTORE",
    "GET",
    "GETBIT",
    "GETDEL",
    "GETEX",
    "GETRANGE",
    "GETSET",
    "GRAPH.CONFIG GET",
    "GRAPH.CONFIG SET",
    "GRAPH.CONSTRAINT CREATE",
    "GRAPH.CONSTRAINT DROP",
    "GRAPH.DELETE",
    "GRAPH.EXPLAIN",
    "GRAPH.LIST",
    "GRAPH.PROFILE",
    "GRAPH.QUERY",
    "GRAPH.RO_QUERY",
    "GRAPH.SLOWLOG",
    "HDEL",
    "HELLO",
    "HEXISTS",
    "HGET",
    "HGETALL",
    "HINCRBY",
    "HINCRBYFLOAT",
    "HKEYS",
    "HLEN",
    "HMGET",
    "HMSET",
    "HRANDFIELD",
    "HSCAN",
    "HSET",
    "HSETNX",
    "HSTRLEN",
    "HVALS",
    "INCR",
    "INCRBY",
    "INCRBYFLOAT",
    "INFO",
    "JSON.ARRAPPEND",
    "JSON.ARRINDEX",
    "JSON.ARRINSERT",
    "JSON.ARRLEN",
    "JSON.ARRPOP",
    "JSON.ARRTRIM",
    "JSON.CLEAR",
    "JSON.DEBUG",
    "JSON.DEBUG MEMORY",
    "JSON.DEL",
    "JSON.FORGET",
    "JSON.GET",
    "JSON.MGET",
    "JSON.NUMINCRBY",
    "JSON.NUMMULTBY",
    "JSON.OBJKEYS",
    "JSON.OBJLEN",
    "JSON.RESP",
    "JSON.SET",
    "JSON.STRAPPEND",
    "JSON.STRLEN",
    "JSON.TOGGLE",
    "JSON.TYPE",
    "KEYS",
    "LASTSAVE",
    "LATENCY DOCTOR",
    "LATENCY GRAPH",
    "LATENCY HISTOGRAM",
    "LATENCY HISTORY",
    "LATENCY LATEST",
    "LATENCY RESET",
    "LCS",
    "LINDEX",
    "LINSERT",
    "LLEN",
    "LMOVE",
    "LMPOP",
    "LOLWUT",
    "LPOP",
    "LPOS",
    "LPUSH",
    "LPUSHX",
    "LRANGE",
    "LREM",
    "LSET",
    "LTRIM",
    "MEMORY DOCTOR",
    "MEMORY MALLOC-STATS",
    "MEMORY PURGE",
    "MEMORY STATS",
    "MEMORY USAGE",
    "MGET",
    "MIGRATE",
    "MODULE LIST",
    "MODULE LOAD",
    "MODULE LOADEX",
    "MODULE UNLOAD",
    "MONITOR",
    "MOVE",
    "MSET",
    "MSETNX",
    "MULTI",
    "OBJECT ENCODING",
    "OBJECT FREQ",
    "OBJECT IDLETIME",
    "OBJECT REFCOUNT",
    "PERSIST",
    "PEXPIRE",
    "PEXPIREAT",
    "PEXPIRETIME",
    "PFADD",
    "PFCOUNT",
    "PFDEBUG",
    "PFMERGE",
    "PFSELFTEST",
    "PING",
    "PSETEX",
    "PSUBSCRIBE",
    "PSYNC",
    "PTTL",
    "PUBLISH",
    "PUBSUB CHANNELS",
    "PUBSUB NUMPAT",
    "PUBSUB NUMSUB",
    "PUBSUB SHARDCHANNELS",
    "PUBSUB SHARDNUMSUB",
    "PUNSUBSCRIBE",
    "QUIT",
    "RANDOMKEY",
    "READONLY",
    "READWRITE",
    "RENAME",
    "RENAMENX",
    "REPLCONF",
    "REPLICAOF",
    "RESET",
    "RESTORE",
    "RESTORE-ASKING",
    "ROLE",
    "RPOP",
    "RPOPLPUSH",
    "RPUSH",
    "RPUSHX",
    "SADD",
    "SAVE",
    "SCAN",
    "SCARD",
    "SCRIPT DEBUG",
    "SCRIPT EXISTS",
    "SCRIPT FLUSH",
    "SCRIPT KILL",
    "SCRIPT LOAD",
    "SDIFF",
    "SDIFFSTORE",
    "SELECT",
    "SET",
    "SETBIT",
    "SETEX",
    "SETNX",
    "SETRANGE",
    "SHUTDOWN",
    "SINTER",
    "SINTERCARD",
    "SINTERSTORE",
    "SISMEMBER",
    "SLAVEOF",
    "SLOWLOG GET",
    "SLOWLOG LEN",
    "SLOWLOG RESET",
    "SMEMBERS",
    "SMISMEMBER",
    "SMOVE",
    "SORT",
    "SORT_RO",
    "SPOP",
    "SPUBLISH",
    "SRANDMEMBER",
    "SREM",
    "SSCAN",
    "SSUBSCRIBE",
    "STRLEN",
    "SUBSCRIBE",
    "SUBSTR",
    "SUNION",
    "SUNIONSTORE",
    "SUNSUBSCRIBE",
    "SWAPDB",
    "SYNC",
    "TDIGEST.ADD",
    "TDIGEST.BYRANK",
    "TDIGEST.BYREVRANK",
    "TDIGEST.CDF",
    "TDIGEST.CREATE",
    "TDIGEST.INFO",
    "TDIGEST.MAX",
    "TDIGEST.MERGE",
    "TDIGEST.MIN",
    "TDIGEST.QUANTILE",
    "TDIGEST.RANK",
    "TDIGEST.RESET",
    "TDIGEST.REVRANK",
    "TDIGEST.TRIMMED_MEAN",
    "TIME",
    "TOPK.ADD",
    "TOPK.COUNT",
    "TOPK.INCRBY",
    "TOPK.INFO",
    "TOPK.LIST",
    "TOPK.QUERY",
    "TOPK.RESERVE",
    "TOUCH",
    "TS.ADD",
    "TS.ALTER",
    "TS.CREATE",
    "TS.CREATERULE",
    "TS.DECRBY",
    "TS.DEL",
    "TS.DELETERULE",
    "TS.GET",
    "TS.INCRBY",
    "TS.INFO",
    "TS.MADD",
    "TS.MGET",
    "TS.MRANGE",
    "TS.MREVRANGE",
    "TS.QUERYINDEX",
    "TS.RANGE",
    "TS.REVRANGE",
    "TTL",
    "TYPE",
    "UNLINK",
    "UNSUBSCRIBE",
    "UNWATCH",
    "WAIT",
    "WAITAOF",
    "WATCH",
    "XACK",
    "XADD",
    "XAUTOCLAIM",
    "XCLAIM",
    "XDEL",
    "XGROUP CREATE",
    "XGROUP CREATECONSUMER",
    "XGROUP DELCONSUMER",
    "XGROUP DESTROY",
    "XGROUP SETID",
    "XINFO CONSUMERS",
    "XINFO GROUPS",
    "XINFO STREAM",
    "XLEN",
    "XPENDING",
    "XRANGE",
    "XREAD",
    "XREADGROUP",
    "XREVRANGE",
    "XSETID",
    "XTRIM",
    "ZADD",
    "ZCARD",
    "ZCOUNT",
    "ZDIFF",
    "ZDIFFSTORE",
    "ZINCRBY",
    "ZINTER",
    "ZINTERCARD",
    "ZINTERSTORE",
    "ZLEXCOUNT",
    "ZMPOP",
    "ZMSCORE",
    "ZPOPMAX",
    "ZPOPMIN",
    "ZRANDMEMBER",
    "ZRANGE",
    "ZRANGEBYLEX",
    "ZRANGEBYSCORE",
    "ZRANGESTORE",
    "ZRANK",
    "ZREM",
    "ZREMRANGEBYLEX",
    "ZREMRANGEBYRANK",
    "ZREMRANGEBYSCORE",
    "ZREVRANGE",
    "ZREVRANGEBYLEX",
    "ZREVRANGEBYSCORE",
    "ZREVRANK",
    "ZSCAN",
    "ZSCORE",
    "ZUNION",
    "ZUNIONSTORE"
]

PIECE_COMMAND_DICT = {
    "ACL": [
        "ACL CAT",
        "ACL DELUSER",
        "ACL DRYRUN",
        "ACL GENPASS",
        "ACL GETUSER",
        "ACL LIST",
        "ACL LOAD",
        "ACL LOG",
        "ACL SAVE",
        "ACL SETUSER",
        "ACL USERS",
        "ACL WHOAMI",
    ],
    "CLIENT": [
        "CLIENT CACHING",
        "CLIENT GETNAME",
        "CLIENT GETREDIR",
        "CLIENT ID",
        "CLIENT INFO",
        "CLIENT KILL",
        "CLIENT LIST",
        "CLIENT NO-EVICT",
        "CLIENT NO-TOUCH",
        "CLIENT PAUSE",
        "CLIENT REPLY",
        "CLIENT SETINFO",
        "CLIENT SETNAME",
        "CLIENT TRACKING",
        "CLIENT TRACKINGINFO",
        "CLIENT UNBLOCK",
        "CLIENT UNPAUSE",
    ],
    "CLUSTER": [
        "CLUSTER ADDSLOTS",
        "CLUSTER ADDSLOTSRANGE",
        "CLUSTER BUMPEPOCH",
        "CLUSTER COUNT-FAILURE-REPORTS",
        "CLUSTER COUNTKEYSINSLOT",
        "CLUSTER DELSLOTS",
        "CLUSTER DELSLOTSRANGE",
        "CLUSTER FAILOVER",
        "CLUSTER FLUSHSLOTS",
        "CLUSTER FORGET",
        "CLUSTER GETKEYSINSLOT",
        "CLUSTER INFO",
        "CLUSTER KEYSLOT",
        "CLUSTER LINKS",
        "CLUSTER MEET",
        "CLUSTER MYID",
        "CLUSTER MYSHARDID",
        "CLUSTER NODES",
        "CLUSTER REPLICAS",
        "CLUSTER REPLICATE",
        "CLUSTER RESET",
        "CLUSTER SAVECONFIG",
        "CLUSTER SET-CONFIG-EPOCH",
        "CLUSTER SETSLOT",
        "CLUSTER SHARDS",
        "CLUSTER SLAVES",
        "CLUSTER SLOTS",
    ],
    "COMMAND": [
        "COMMAND",
        "COMMAND COUNT",
        "COMMAND DOCS",
        "COMMAND GETKEYS",
        "COMMAND GETKEYSANDFLAGS",
        "COMMAND INFO",
        "COMMAND LIST",
    ],
    "CONFIG": [
        "CONFIG GET",
        "CONFIG RESETSTAT",
        "CONFIG REWRITE",
        "CONFIG SET",
    ],
    "FUNCTION": [
        "FUNCTION DELETE",
        "FUNCTION DUMP",
        "FUNCTION FLUSH",
        "FUNCTION KILL",
        "FUNCTION LIST",
        "FUNCTION LOAD",
        "FUNCTION RESTORE",
        "FUNCTION STATS",
    ],
    "LATENCY": [
        "LATENCY DOCTOR",
        "LATENCY GRAPH",
        "LATENCY HISTOGRAM",
        "LATENCY HISTORY",
        "LATENCY LATEST",
        "LATENCY RESET",
    ],
    "MEMORY": [
        "MEMORY DOCTOR",
        "MEMORY MALLOC-STATS",
        "MEMORY PURGE",
        "MEMORY STATS",
        "MEMORY USAGE",
    ],
    "MODULE": [
        "MODULE LIST",
        "MODULE LOAD",
        "MODULE LOADEX",
        "MODULE UNLOAD",
    ],
    "OBJECT": [
        "OBJECT ENCODING",
        "OBJECT FREQ",
        "OBJECT IDLETIME",
        "OBJECT REFCOUNT",
    ],
    "PUBSUB": [
        "PUBSUB CHANNELS",
        "PUBSUB NUMPAT",
        "PUBSUB NUMSUB",
        "PUBSUB SHARDCHANNELS",
        "PUBSUB SHARDNUMSUB",
    ],
    "SCRIPT": [
        "SCRIPT DEBUG",
        "SCRIPT EXISTS",
        "SCRIPT FLUSH",
        "SCRIPT KILL",
        "SCRIPT LOAD",
    ],
    "SLOWLOG": [
        "SLOWLOG GET",
        "SLOWLOG LEN",
        "SLOWLOG RESET",
    ],
    "XGROUP": [
        "XGROUP CREATE",
        "XGROUP CREATECONSUMER",
        "XGROUP DELCONSUMER",
        "XGROUP DESTROY",
        "XGROUP SETID",
    ],
    "XINFO": [
        "XINFO CONSUMERS",
        "XINFO GROUPS",
        "XINFO STREAM",
    ]
}

# 通用命令
REDIS_GENERIC_KEY_LIST = [
    "KEYS",
    "DEL",
    "OBJECT",
    "EXISTS",
    "EXPIRE",
    "MOVE",
    "PERSIST",
    "PTTL",
    "RANDOMKEY",
    "RENAME",
    "RENAMENX",
    "SCAN",
    "SORT",
    "TTL",
    "TYPE",  # 引号处理
]

# 字符串命令
REDIS_STRING_KEY_LIST = [
    "APPEND",
    "BITCOUNT",
    "BITOP",
    "BITPOS",
    "DECR",
    "DECRBY",
    "GET",
    "GETRANGE",
    "GETSET",
    "INCR",
    "INCRBY",
    "INCRBYFLOAT",
    "MGET",
    "MSET",
    "MSETNX",
    "PSETEX",
    "SET",
    "SETBIT",
    "SETEX",
    "SETNX",
    "SETRANGE",
    "STRLEN",
    "BITFIELD",
]

# 列表命令
REDIS_LIST_KEY_LIST = [
    "LPUSH",
    "RPUSH",
    "RPUSHX",
    "BRPOPLRUSH",
    "LINDEX",
    "LINSERT",
    "LLEN",
    "LPOP",
    "LPUSHX",
    "LRANGE",
    "LREM",
    "LSET",
    "LTRIM",
    "RPOP",
    "RPOPLPU",
    "RPOPLPUSH",
]

# 集合命令
REDIS_SET_KEY_LIST = [
    "SADD",
    "SCARD",
    "SDIFF",
    "SDIFFSTORE",
    "SINTER",
    "SINTERSTORE",
    "SISMEMBER",
    "SMEMBERS",
    "SMOVE",
    "SPOP",
    "SRANDMEMBER",
    "SREM",
    "SUNION",
    "SUNIONSTORE",
    "SSCAN",
]

# 有序集合命令
REDIS_SORTED_SET_KEY_LIST = [
    "ZADD",
    "ZCARD",
    "ZCOUNT",
    "ZINCRBY",
    "ZRANGE",
    "ZRANGEBYSCORE",
    "ZRANK",
    "ZREMRANGEBYRANK",
    "ZREMRANGEBYCORE",
    "ZREVRANGE",
    "ZREVRANGEBYSCORE",
    "ZREVRANK",
    "ZSCORE",
    "ZUNIONSTORE",
    "ZINTERSTORE",
    "ZSCAN",
    "ZRANGEBYLEX",
    "ZLEXCOUNT",
]

# 服务命令
REDIS_SORTED_SERVER_KEY_LIST = [
    # "FLUSHALL",  # 返回值处理，危险命令暂时不支持使用（删除全部库数据）
    "FLUSHDB",  # 返回值处理（删除当前库数据）
    "DBSIZE",
    "TIME",  # 引号处理
    "INFO",  # 引号处理
    "CLIENT KILL",
    "CLIENT LIST",  # 引号处理
    "CLIENT GETNAME",
    "CLIENT SETNAME",
    "CONFIG GET",
    # "MONITOR",
    "SLOWLOG",
    "ROLE",
    "SWAPDB",
    "MEMORY",
]

# 字典命令
REDIS_SORTED_HASH_KEY_LIST = [
    "HDEL",
    "HEXISTS",
    "HGET",
    "HGETALL",
    "HINCRBY",
    "HINCRBYFLOAT",
    "HKEYS",
    "HMGET",
    "HMSET",
    "HSET",
    "HSETNX",
    "HVALS",
    "HSCAN",
    "HSTRLEN",
]

# # 消息订阅命令
# REDIS_SORTED_PUB_SUB_KEY_LIST = [
#     "PSUBSCRIBE",
#     "PUBLISH",
#     "PUBSUB",
#     "PUNSUBSCRIBE",
#     "SUBSCRIBE",
#     "UNSUBSCRIBE",
# ]

# 基数统计命令
REDIS_SORTED_HYPER_LOG_KEY_LIST = [
    "PFADD",
    "PFCOUNT",
    "PFMERGE",
]

# 连接命令
REDIS_SORTED_CONNECTION_KEY_LIST = [
    # "AUTH",
    "ECHO",
    "PING",  # 返回值处理 引号处理
    "QUIT",
]

# 脚本命令
REDIS_SORTED_SCRIPTING_KEY_LIST = [
    "EVAL",
    "EVALSHA",
    "SCRIPT EXISTS",
    "SCRIPT FLUSH",
    "SCRIPT KILL",
    "SCRIPT LOAD",
]

# 地图命令
REDIS_SORTED_GEO_KEY_LIST = [
    "GEOADD",
    "GEOHASH",
    "GEOPOS",
    "GEODIST",
    "GEORADIUS",
    "GEORADIUSBYMEMBER",
]

# REDIS_SORTED_PUB_SUB_KEY_LIST
REDIS_SUPPORT_KEY_LIST = REDIS_GENERIC_KEY_LIST + REDIS_STRING_KEY_LIST + REDIS_LIST_KEY_LIST + REDIS_SET_KEY_LIST + REDIS_SORTED_SET_KEY_LIST + REDIS_SORTED_SERVER_KEY_LIST + REDIS_SORTED_HASH_KEY_LIST + REDIS_SORTED_HYPER_LOG_KEY_LIST + REDIS_SORTED_CONNECTION_KEY_LIST + REDIS_SORTED_SCRIPTING_KEY_LIST + REDIS_SORTED_GEO_KEY_LIST

# 有些命令小写输出更加友好，将其使用小写执行
COMMAND_CLEAN_LOWER_COMMAND_LIST = ["INFO", "CLIENT LIST"]
# 有些命令返回
COMMAND_CLEAN_RETURN_DICT = {
    "PING": "PONG",
    "FLUSHALL": "OK",
    "FLUSHDB": "OK",
}